const CryptoJS = require("crypto-js");
const user = require("./user").default
function getTimer(){
  let aseKey = "12345678"
  let message = String(new Date().getTime() - 1000000000000);
  let encrypt = CryptoJS.AES.encrypt(message, CryptoJS.enc.Utf8.parse(aseKey), {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  }).toString();
  return encodeURIComponent(encrypt)
}
function getToken(id){
  let aseKey = "19491001"
  let message = id?id:localStorage.getItem("haust-twxsh-id")
  let encrypt = CryptoJS.AES.encrypt(String(message), CryptoJS.enc.Utf8.parse(aseKey), {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  }).toString();
  return encodeURIComponent(encrypt)
}

function formatDate(date){
  if(typeof date =='string'){
    return date
  }
  return `${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()}`
}

export default {
  getTimer,getToken,formatDate
}
